package com.jz.pay3.design.observer;

public class Client {
    public static void main(String[] args) {
        // 主题
        Subject teacher = new Teacher("王老师","18581903441");

        // 观察者
        Observer student1 = new Student("小刘1",teacher);
        student1.show();
        teacher.addObserver(student1);
        student1.show();

        Observer student2 = new Student("小刘2",teacher);
        student2.show();
        teacher.addObserver(student2);
        student2.show();

        Observer student3 = new Student("小刘3",teacher);
        student3.show();
        teacher.addObserver(student3);
        student3.show();

        Observer student4 = new Student("小刘4",teacher);
        student4.show();
        teacher.addObserver(student4);
        student4.show();

        Observer student5 = new Student("小刘5",teacher);
        student5.show();
        teacher.addObserver(student5);
        student5.show();


        System.out.println("===========修改手机号通知");
        teacher.modify("12345678910");

        student1.show();
        student2.show();
        student3.show();
        student4.show();
        student5.show();

        teacher.rmObserver(student1);
        teacher.rmObserver(student2);
        teacher.rmObserver(student3);
        teacher.rmObserver(student4);
        teacher.rmObserver(student5);

        System.out.println("===========移除观察者");
        student1.show();
        student2.show();
        student3.show();
        student4.show();
        student5.show();
    }
}
